
// 用户端接口文件

'use strict';
const { Controller } = require('egg');

class cUser extends Controller {
    // 注册接口
    async wa_c_register() {
        const { ctx } = this;
        console.log(ctx.request.body, "获取从前端传递过来的参数");
        const result = await ctx.service.sUser.wa_s_create(ctx?.request?.body ?? {});
        ctx.body = result;
    }

    // 用户账户登录接口
    async wa_c_login() {
        const { ctx } = this;
        console.log(ctx.request.body, "获取从前端传递过来的参数");
        const result = await ctx.service.sUser.wa_s_login(ctx?.request?.body ?? {});
        ctx.body = result;
    }

    // 用户账户查询
    async wa_c_query() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_query(ctx?.query ?? {});
        ctx.body = result;
    }

    // 用户余额查询
    async wa_c_getUserBalance() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_getUserBalance(ctx?.query ?? {});
        ctx.body = result;
    }

    // 用户账户修改
    async wa_c_update() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_update(ctx?.request?.body ?? {});
        ctx.body = result;
    }

    // 用户账户删除
    async wa_c_delete() {
        // console.log('?? - wa_c_delete');
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_delete(ctx?.query ?? {});
        ctx.body = result;
    }

    //Web端用户购物车查询
    async pc_c_query_cart() {
        const { ctx } = this;
        const result = await ctx.service.sUser.pc_s_query_cart(ctx?.query ?? {});
        ctx.body = result;
    }

    // Web端用户购物车更新
    async pc_c_update_cart() {
        const { ctx } = this;
        const result = await ctx.service.sUser.pc_s_update_cart(ctx?.request?.body ?? {});
        ctx.body = result;
    }





    //用户地址查询
    async wa_c_query_address() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_query_address(ctx?.query ?? {});
        ctx.body = result;
    }

    // 用户地址新增
    async wa_c_create_address() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_create_address(ctx?.request?.body ?? {});
        ctx.body = result;
    }

    // 用户地址修改
    async wa_c_update_address() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_update_address(ctx?.request?.body ?? {});
        ctx.body = result;
    }
     //设置用户默认地址
     async wa_c_setdefault_address() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_setdefault_address(ctx?.request?.body ?? {});
        ctx.body = result;
    }

    // 用户地址删除
    async wa_c_delete_address() {
        const { ctx } = this;
        const result = await ctx.service.sUser.wa_s_delete_address(ctx?.request?.body ?? {});
        ctx.body = result;
    }
}

module.exports = cUser;